#!/bin/python
# -*- coding: utf-8 -*-

import sys, os, stat
import platform

class Master():
	def __init__(self):
		pass

	def Run(self, argv):
		if len(argv) != 4:
			print "args failed"
		else:
			self._fullpathA = argv[1]
			self._fullpathB = argv[2]
			self._pathDst 	= argv[3]

			LangExt = '%s/Tools/lua/LangExt.lua' % os.getcwd()

			if not os.path.exists(self._pathDst):
				os.makedirs(self._pathDst)

			self.InitCommand()

			os.system('%s %s %s %s %s' % (self._cmd, LangExt, self._fullpathA, self._fullpathB, self._pathDst))

	def InitCommand(self):
		self._cmd = ''
		if 'Windows' in platform.system():
			# Windows
			self._cmd += 'lua.exe'
			os.chdir(os.path.normpath('Tools/lua/win'))

		elif 'Darwin' in platform.system():
			# OSX
			self._cmd += './lua'

			os.chdir(os.path.normpath('Tools/lua/mac'))
			os.chmod(self._cmd, stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
		

if __name__ == '__main__':
	Master().Run(sys.argv)
